import 'dart:io';
import 'package:flutter/services.dart';
import 'package:flutter_uikit/t2mini/bean/CardBean.dart';
import 'package:flutter_uikit/t2mini/bean/PayBean.dart';
import 'package:flutter_uikit/t2mini/ui/net/network.dart';

//  NativeCall.getInstance().getPamars({
//     "type": "20",
//     "code": "183727",
//     "shop": "107",
//     "term": "142",
//     "ver": "20201223"
//   });

class NativeCall {
  static MethodChannel methodChannel;
  static NativeCall nativeCall;
  static NativeCall getInstance() {
    if (nativeCall == null) {
      nativeCall = new NativeCall();
      nativeCall.nativeChannel();
    }
    return nativeCall;
  }

  Future<void> nativeChannel() async {
    if (Platform.isIOS) {
      methodChannel = MethodChannel("demo.gawkat.com/info");
    } else if (Platform.isAndroid) {
      methodChannel = MethodChannel("com.sovell.android.channel");
    }
  }

  Future<void> getPamars(Map<String, String> parm) async {
    var result = await methodChannel.invokeMethod("getMessage", parm);
    DiaoUtil.sign2(result);
  }

  //  params.put("cid", cid);
  //     params.put("account", "-1");//-1为全部账户
  Future<CardBean> cardGet(var parm) async {
    var result = await methodChannel.invokeMethod("getMessage", parm);
    return DiaoUtil.cardGet(result);
  }

//  params.put("t", ParamsUtil.T_2111);
//         params.put("part", part);
//         params.put("prods", prods);
//         params.put("amt", amt);
//         params.put("pays", pays);
//         params.put("policy", "1");
//         params.put("d", date);
//         params.put("pay_date", payDate);
//         params.put("invoice", invoice);
//         params.put("auto_account", "1");
//         params.put("gage", gage);

  Future<PayBean> dishPay(var parm) async {
    var result = await methodChannel.invokeMethod("getMessage", parm);
    print("入参=" + result.toString());
    return DiaoUtil.dishPay(result);
  }

  void test21() {}
}
